/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package queenb.web.timekeeper.controller;

import java.text.ParseException;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;
import javax.faces.model.SelectItem;
import queenb.net.entitybean.N150;
import queenb.web.controller.QueenbController;
import queenb.web.timekeeper.inteface.N150Inf;
import queenb.web.timekeeper.store.N150Store;
import queenb.web.util.ComboboxUtil;
import queenb.web.util.ContextUtil;
import queenb.web.util.SessionProvider;
import queenb.web.util.Util;

/**
 *
 * @author Administrator
 */
public class TimekeeperController extends QueenbController{
  private int pn150;
    private String cv251;
    private String cv254;
    private String cv255;
    private String hoten;
    private String nv116;
    private String nv120;
    private String nv121;
    private String nv151;
    private String WKTIME;
    private Date nd152;
    private String nv153;
    private Date nd157;
    private String nv158;
    private int fc250;
    private String status;
    private N150Inf n150Inf;
    private N150Store n150Store;
    private ComboboxUtil comboboxUtil = new ComboboxUtil();
    private List<SelectItem> listCombC250  =new ArrayList<SelectItem>();
    private List<SelectItem> listCombN100 =new ArrayList<SelectItem>();
    private String keySearch;
    private int typeSearch = 0;
    public TimekeeperController() {
        getKapiMenu().setAdmin(false);
        getKapiMenu().setMainmenu1("m11");
        n150Store = new N150Store();
        listCombC250 = comboboxUtil.getListCombC250();
        listCombN100 = comboboxUtil.getListCombN100();
    }
    public void reload() {
        System.out.println("00000000000000000000000000000000000000000000000000000" + getKeySearch() + getTypeSearch());
        SessionProvider.setSessionMapValue("submitSearch", "false");
    }
    
    //List comb c250
    public List<SelectItem> getListCombC250(){
       return listCombC250;
    }
    
    public List<SelectItem> getListCombN100(){
       return listCombN100;
    }
    public void updateN150By() throws ParseException {
        int roweffect = 0;
        String date = "";
        date = ContextUtil.getRequestParameter("example1");
        java.sql.Timestamp date1 = null;
        if(!date.equals("")){
             java.util.Date dateStart = new Date(date);
              date1 = new java.sql.Timestamp(dateStart.getTime());
        }

       
       
        System.out.println("-----date convert ---"+date1);
         System.out.println("---insert ---"+this.getPn150()+","+getLogin().getModule()+","+ getLogin().getCompanyNo()+","+ this.getFc250()+","+ this.getNv151()+","+Util.toSQLDate(this.getNd152())+","+ this.getNv116()+","+ getLogin().getUserName());
        roweffect = n150Store.updateN150(this.getPn150(), getLogin().getModule(), getLogin().getCompanyNo(), this.getFc250(), this.getNv151(),date1, this.getNv116(), getLogin().getUserName());
        if (roweffect >= 0) {
            showGlobalReport(true, getResourceString("datasavesuccessful"));
            sendRedirect("timekeeper.jsp");

        } else {
            showGlobalReport(true, getResourceString("datasuccessfail"));
        }
       
    }
    public List<N150> getListTabN150() 
    {
        try{
            Date f  = new Date(112, 7, 1);
            Date t  = new Date(112, 8, 30);
            List<N150> lst= n150Store.listTabN150(getLogin().getModule(), getLogin().getCompanyNo(), 0, 0,Util.toSQLDate(f),Util.toSQLDate(t), getLogin().getUserName());
            return lst;
        }catch(Exception ex){
            return  null;
        }
    }
     public List<N150> getListTabN150Late() 
    {
        try{
            Date f  = new Date(112, 7, 1);
            Date t  = new Date(112, 8, 30);
            List<N150> lst= n150Store.listTabN150Late(getLogin().getModule(), getLogin().getCompanyNo(), 0, 0,Util.toSQLDate(f),Util.toSQLDate(t), getLogin().getUserName());
            return lst;
        }catch(Exception ex){
            return  null;
        }
    }

    /**
     * @return the cv251
     */
    public String getCv251() {
        return cv251;
    }

    /**
     * @param cv251 the cv251 to set
     */
    public void setCv251(String cv251) {
        this.cv251 = cv251;
    }

    /**
     * @return the cv254
     */
    public String getCv254() {
        return cv254;
    }

    /**
     * @param cv254 the cv254 to set
     */
    public void setCv254(String cv254) {
        this.cv254 = cv254;
    }

    /**
     * @return the cv255
     */
    public String getCv255() {
        return cv255;
    }

    /**
     * @param cv255 the cv255 to set
     */
    public void setCv255(String cv255) {
        this.cv255 = cv255;
    }

    /**
     * @return the hoten
     */
    public String getHoten() {
        return hoten;
    }

    /**
     * @param hoten the hoten to set
     */
    public void setHoten(String hoten) {
        this.hoten = hoten;
    }

    /**
     * @return the nv116
     */
    public String getNv116() {
        return nv116;
    }

    /**
     * @param nv116 the nv116 to set
     */
    public void setNv116(String nv116) {
        this.nv116 = nv116;
    }

    /**
     * @return the nv120
     */
    public String getNv120() {
        return nv120;
    }

    /**
     * @param nv120 the nv120 to set
     */
    public void setNv120(String nv120) {
        this.nv120 = nv120;
    }

    /**
     * @return the nv121
     */
    public String getNv121() {
        return nv121;
    }

    /**
     * @param nv121 the nv121 to set
     */
    public void setNv121(String nv121) {
        this.nv121 = nv121;
    }

    /**
     * @return the nv151
     */
    public String getNv151() {
        return nv151;
    }

    /**
     * @param nv151 the nv151 to set
     */
    public void setNv151(String nv151) {
        this.nv151 = nv151;
    }

    /**
     * @return the nd152
     */
    public Date getNd152() {
        return nd152;
    }

    /**
     * @param nd152 the nd152 to set
     */
    public void setNd152(Date nd152) {
        this.nd152 = nd152;
    }

    /**
     * @return the nv153
     */
    public String getNv153() {
        return nv153;
    }

    /**
     * @param nv153 the nv153 to set
     */
    public void setNv153(String nv153) {
        this.nv153 = nv153;
    }

    /**
     * @return the nd157
     */
    public Date getNd157() {
        return nd157;
    }

    /**
     * @param nd157 the nd157 to set
     */
    public void setNd157(Date nd157) {
        this.nd157 = nd157;
    }

    /**
     * @return the nv158
     */
    public String getNv158() {
        return nv158;
    }

    /**
     * @param nv158 the nv158 to set
     */
    public void setNv158(String nv158) {
        this.nv158 = nv158;
    }

    /**
     * @return the pn150
     */
    public int getPn150() {
        return pn150;
    }

    /**
     * @param pn150 the pn150 to set
     */
    public void setPn150(int pn150) {
        this.pn150 = pn150;
    }

    /**
     * @return the fc250
     */
    public int getFc250() {
        return fc250;
    }

    /**
     * @param fc250 the fc250 to set
     */
    public void setFc250(int fc250) {
        this.fc250 = fc250;
    }

    /**
     * @return the n150Inf
     */
    public N150Inf getN150Inf() {
        return n150Inf;
    }

    /**
     * @param n150Inf the n150Inf to set
     */
    public void setN150Inf(N150Inf n150Inf) {
        this.n150Inf = n150Inf;
    }   

    /**
     * @param listCombC250 the listCombC250 to set
     */
    public void setListCombC250(List<SelectItem> listCombC250) {
        this.listCombC250 = listCombC250;
    }

    /**
     * @param listCombN100 the listCombN100 to set
     */
    public void setListCombN100(List<SelectItem> listCombN100) {
        this.listCombN100 = listCombN100;
    }

    /**
     * @return the status
     */
    public String getStatus() {
        return status;
    }

    /**
     * @param status the status to set
     */
    public void setStatus(String status) {
        this.status = status;
    }

    /**
     * @return the keySearch
     */
    public String getKeySearch() {
        return keySearch;
    }

    /**
     * @param keySearch the keySearch to set
     */
    public void setKeySearch(String keySearch) {
        this.keySearch = keySearch;
    }

    /**
     * @return the typeSearch
     */
    public int getTypeSearch() {
        return typeSearch;
    }

    /**
     * @param typeSearch the typeSearch to set
     */
    public void setTypeSearch(int typeSearch) {
        this.typeSearch = typeSearch;
    }

    /**
     * @return the WKTIME
     */
    public String getWKTIME() {
        return WKTIME;
    }

    /**
     * @param WKTIME the WKTIME to set
     */
    public void setWKTIME(String WKTIME) {
        this.WKTIME = WKTIME;
    }
    
}
